<template>
  <div class="center-warp">
    <div class="center-content-body">
      <div class="content-gear-group" :class="{'rotate-gear-group':rotateGear}">
        <div class="gear-item out-gear"></div>
        <div class="gear-item gear-inner-1"></div>
        <div class="gear-item gear-inner-2"></div>
        <div class="gear-item gear-inner-3"></div>
        <div class="gear-item gear-inner-3-1"></div>
        <div class="gear-item gear-inner-4"></div>
        <div class="gear-item gear-inner-5"></div>
        <div class="gear-item gear-inner-6"></div>
        <div class="gear-item inner-triangle">
          <div class="inner-triangle-item"></div>
          <div class="inner-triangle-item"></div>
          <div class="inner-triangle-item"></div>
          <div class="inner-triangle-item"></div>

          <div class="inner-triangle-cont">{{numberValue}}</div>
        </div>
      </div>

      <div class="content-card-group" v-show="show">
        <div
            class="ball"
            :class="[`status-${item.appRunState}`]"
            v-for="(item, index) in list"
            :key="item.id + index"
            @click="handelBall(item.id, index + 1)">
          <div class="img-dom">
            <div class="img-dom-1">
              <div class="app-name">{{ item.appName }}</div>
              <div class="app-sub">{{ item.appScene }}</div>
            </div>
            <div class="num-box">{{ item.pluginsNum }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {absolute} from "@antv/x6/lib/registry/port-layout/absolute";

export default {
  props: {
    list: {
      type: Array,
      default: () => {
        return [];
      },
    },
  },
  data() {
    return {
      numberValue: 1,
      show: false,
      rotateGear: false
    };
  },
  computed: {
    camListNum() {
      return this.list.length || 0
    },
  },
  mounted() {
    this.$nextTick(() => {
      this.rotateGear = true
      setTimeout(() => {
        this.show = true
      }, 3000)
      this.handleC();
    });
  },
  methods: {
    handleC() {
      let items = document.getElementsByClassName("ball");
      for (let i = 0; i < items.length; i++) {
        items[i].classList.add(`ball${i + 1}`);
      }
      for (let i = 0; i < items.length; i++) {
        items[i].addEventListener("mouseover", function () {
          for (let j = 0; j < items.length; j++) {
            items[j].style.animationPlayState = "paused";
          }
        });
        items[i].addEventListener("mouseout", function () {
          for (let j = 0; j < items.length; j++) {
            items[j].style.animationPlayState = "running";
          }
        });
      }
    },
    handelBall(id, data) {
      this.numberValue = data;
      this.$emit("handelBall", id);
    },
  },
};
</script>

<style lang="scss" scoped>
  $error: red;
  $blue: blue;
  $orange: #f7903d;
  $success: #2aef8a;
  $gray: gray;

  .center-warp {
    height: 100%;
    width: 100%;
    transform-style: preserve-3d;
    perspective: 8000px;
  }

  .center-content-body {
    height: 100%;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    /*transform-style: preserve-3d;*/
    perspective: 8000px;
    position: relative;

    .content-gear-group {
      width: 400px;
      height: 400px;
      border-radius: 50%;
      position: relative;
      transform-style: preserve-3d;
      perspective: 8000px;
      transition: all 2s;
      display: flex;
      align-items: center;
      justify-content: center;
      transition-delay: 1s;

      &.rotate-gear-group {
        transform: rotateX(60deg);
      }

      .gear-item {
        position: absolute;
        margin: auto;
        width: 100%;
        height: 100%;
        transform-style: preserve-3d;
        background-repeat: no-repeat;
        background-size: cover;
        background-position: center center;
      }

      .out-gear {
        background-image: url("~@/assets/img/center/gear.png");
        animation: along_rotate 9s linear 3s infinite;
      }

      .gear-inner-1 {
        width: 93%;
        height: 93%;
        background-image: url("~@/assets/img/center/gear-inner-1.png");
        animation: back_rotate 5s linear 3s infinite;
      }

      .gear-inner-2 {
        width: 90%;
        height: 90%;
        background-image: url("~@/assets/img/center/gear-inner-2.png");
        transform: translateZ(10px);
      }

      .gear-inner-3 {
        width: 75%;
        height: 75%;
        background-image: url("~@/assets/img/center/gear-inner-3.png");
        transform: translateZ(25px);
      }

      .gear-inner-3-1 {
        width: 75%;
        height: 75%;
        background-image: url("~@/assets/img/center/gear-inner-3-1.png");
        transform: translateZ(25px);
        animation: along_rotate3-1 4s linear 3s infinite;
      }

      .gear-inner-4 {
        /*border: 2px solid #409eff;*/
        /*border-radius: 50%;*/

        width: 60%;
        height: 60%;
        background-image: url("~@/assets/img/center/gear-inner-4.png");
        transform: translateZ(30px);
      }

      /*白色半圆*/

      .gear-inner-5 {
        width: 55%;
        height: 55%;
        /*border: 1px solid #fff;*/
        /*border-radius: 50%;*/
        /*border-bottom-color: transparent;*/
        /*border-top-color: transparent;*/

        background-image: url("~@/assets/img/center/gear-inner-5.png");
        transform: translateZ(30px);
        animation: dom_rotate1 4s linear 3s infinite;
      }

      .gear-inner-6 {
        width: 45%;
        height: 45%;
        background-image: url("~@/assets/img/center/gear-inner-6.png");
        transform: translateZ(30px);
      }

      .inner-triangle {
        width: 40%;
        height: 40%;
        position: absolute;
        transform: translateZ(30px) rotate(45deg);
        display: flex;
        align-items: center;
        justify-content: center;


        .inner-triangle-item {
          position: absolute;
          width: 15px;
          height: 15px;
          /*background-color: rgba(255, 255, 255, 0.3);*/
          background-image: url("~@/assets/img/center/inner-triangle.png");
          background-repeat: no-repeat;
          background-size: 100% 100%;
          background-position: center center;

          &:nth-child(1) {
            top: 0;
            left: 0;
            right: 0;
            margin: 0 auto;
            transform: rotate(180deg) translateY(0);
            animation: triangle-1 2s linear 3s infinite;
          }

          &:nth-child(2) {
            top: 0;
            right: 0;
            bottom: 0;
            margin: auto 0;
            transform: rotate(-90deg) translateY(0);
            animation: triangle-2 2s linear 3s infinite;
          }

          &:nth-child(3) {
            bottom: 0;
            left: 0;
            right: 0;
            margin: 0 auto;
            transform: rotate(0) translateY(0);
            animation: triangle-3 2s linear 3s infinite;
          }

          &:nth-child(4) {
            top: 0;
            left: 0;
            bottom: 0;
            margin: auto 0;
            transform: rotate(90deg) translateY(0);
            animation: triangle-4 2s linear 3s infinite;
          }
        }

        .inner-triangle-cont {
          position: absolute;
          margin: auto 0;
          transform: rotate(-45deg) translateZ(0px);
          color: #ffffff;
          font-size: 30px;
        }
      }
    }

    .content-card-group {
      width: 1px;
      height: 1px;
      margin: 0 auto;
      border-radius: 50%;
      position: absolute;
      z-index: 100;
      left: calc(50% - 480px);
      top: 45px;
      transform-style: preserve-3d;
      transform: translateZ(100px);

      .ball {
        width: 268px;
        height: 90px;
        cursor: pointer;
        position: absolute;
        color: #fff;
        font-size: 22px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: url("~@/assets/img/indexHome/slices/card-1.png") no-repeat;
        border-radius: 10px;
        padding: 15px;
        transform-origin: center;

        &.status-0 {
          background-color: $success;
        }

        &.status-1 {
          background-color: $blue;
        }

        &.status-2 {
          background-color: $error;
        }

        &.status-3 {
          background-color: $gray;
        }

        .img-dom {
          width: 100%;
          display: flex;
          align-items: center;
          height: 100%;

          .img-dom-1 {
            display: flex;
            flex: 1;
            flex-direction: column;
            justify-content: center;

            .app-name {
              margin-bottom: 10px;
            }

            .app-sub {
              font-size: 14px;
            }
          }

          .num-box {
            white-space: nowrap;
            width: 40px;
          }
        }
      }


      .ball1 {
        animation: animX 10s cubic-bezier(0.36, 0, 0.64, 1) -5s infinite alternate,
        animY 10s cubic-bezier(0.36, 0, 0.64, 1) 0s infinite alternate,
        scale 20s cubic-bezier(0.36, 0, 0.64, 1) 0s infinite alternate;
      }

      .ball2 {
        animation: animX 10s cubic-bezier(0.36, 0, 0.64, 1) -9s infinite alternate,
        animY 10s cubic-bezier(0.36, 0, 0.64, 1) -4s infinite alternate,
        scale 20s cubic-bezier(0.36, 0, 0.64, 1) -4s infinite alternate;
      }

      .ball3 {
        animation: animX 10s cubic-bezier(0.36, 0, 0.64, 1) -13s infinite alternate,
        animY 10s cubic-bezier(0.36, 0, 0.64, 1) -8s infinite alternate,
        scale 20s cubic-bezier(0.36, 0, 0.64, 1) -8s infinite alternate;
      }

      .ball4 {
        animation: animX 10s cubic-bezier(0.36, 0, 0.64, 1) -17s infinite alternate,
        animY 10s cubic-bezier(0.36, 0, 0.64, 1) -12s infinite alternate,
        scale 20s cubic-bezier(0.36, 0, 0.64, 1) -12s infinite alternate;
      }

      .ball5 {
        animation: animX 10s cubic-bezier(0.36, 0, 0.64, 1) -21s infinite alternate,
        animY 10s cubic-bezier(0.36, 0, 0.64, 1) -16s infinite alternate,
        scale 20s cubic-bezier(0.36, 0, 0.64, 1) -16s infinite alternate;
      }
    }
  }

  /*顺时针*/
  @keyframes along_rotate {
    0% {
      transform: rotate(0deg);
    }

    100% {
      transform: rotate(360deg);
    }
  }

  /*逆时针*/
  @keyframes back_rotate {
    0% {
      transform: rotate(360deg);
    }

    100% {
      transform: rotate(0deg);
    }
  }

  @keyframes along_rotate3-1 {
    0% {
      transform: rotate(0deg) translateZ(25px);
    }

    100% {
      transform: rotate(360deg) translateZ(25px);
    }
  }


  @keyframes dom_rotate1 {
    0% {
      transform: rotate(0deg) translateZ(30px);
    }
    50% {
      transform: rotate(-45deg) translateZ(30px);
    }
    100% {
      transform: rotate(0deg) translateZ(30px);
    }
  }


  @keyframes dom_rotate3 {
    0% {
      transform: rotate(0deg);
    }
    25% {
      transform: rotate(90deg);
    }
    50% {
      transform: rotate(180deg);
    }
    75% {
      transform: rotate(240deg);
    }
    100% {
      transform: rotate(360deg);
    }
  }

  @keyframes run {
    from {
      transform: rotateZ(0);
    }

    to {
      transform: rotateZ(360deg);
    }
  }

  @keyframes triangle-1 {
    0% {
      transform: rotate(180deg) translateY(0);
    }

    50% {
      transform: rotate(180deg) translateY(-20px);
    }

    100% {
      transform: rotate(180deg) translateY(0);
    }
  }

  @keyframes triangle-2 {
    0% {
      transform: rotate(-90deg) translateY(0);
    }

    50% {
      transform: rotate(-90deg) translateY(-20px);
    }

    100% {
      transform: rotate(-90deg) translateY(0);
    }
  }

  @keyframes triangle-3 {
    0% {
      transform: rotate(0) translateY(0);
    }

    50% {
      transform: rotate(0) translateY(-20px);
    }

    100% {
      transform: rotate(0) translateY(0);
    }
  }

  @keyframes triangle-4 {
    0% {
      transform: rotate(90deg) translateY(0);
    }

    50% {
      transform: rotate(90deg) translateY(-20px);
    }

    100% {
      transform: rotate(90deg) translateY(0);
    }
  }

  /* 圆环围绕运动 */
  @keyframes animX {
    0% {
      left: 0;
    }

    100% {
      left: 700px;
    }
  }

  @keyframes animY {
    0% {
      top: 0;
    }

    100% {
      top: 300px;
    }
  }

  @keyframes scale {
    0% {
      transform: scale(0.7);
    }

    50% {
      transform: scale(1);
    }

    100% {
      transform: scale(0.7);
    }
  }
</style>
